#include<iostream>
using namespace std;

#include <emmintrin.h>

#pragma GCC option("sse2")
int ShiftWidth(int Mask);
int main()
{

    char Content[]="this is a test string for search\n,this is second line\n, this is third line\n";
    char *pContent = Content;
    int Len = sizeof(Content) - 1;
    while( pContent < Content + Len )
    {
        __v16qi newlines = { '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n' };
        __m128i msg_bytes = _mm_loadu_si128(reinterpret_cast<__m128i *>(pContent));
        __m128i newline_cmp = _mm_cmpeq_epi8(msg_bytes, reinterpret_cast<__m128i>(newlines));
        int newline_msk = _mm_movemask_epi8(newline_cmp);

        if( newline_msk == 0 )
        {
            pContent += 16;
        }
        else
        {
            pContent += ShiftWidth(newline_msk);
            break;
        }

    }

    cout<<pContent<<endl;

}

int ShiftWidth(int Mask)
{
    int Count = 0;
    while( !(Mask & 0x00000001) )
    {
        Mask >>= 1;
        ++Count;
    }

    return Count;
}

